from functools import wraps
import logging

def logged(level,name=None,message=None):
	
	def decrate(func):
		logname = name if name else func.__module__
		log = logging.getLogger(logname)
		logmsg = message if message else func.__name__
		
		@wraps(func)
		def wrapper(*args,**kwargs):
			log.log(level,logmsg)
			return func(*args,**kwargs)
		return wrapper
	return decrate
	
@logged(logging.CRITICAL,"example")
def add(x,y):
	return x-y
	
print add(2,3)